module.exports = {
  type(obj) {
    return (obj === null || obj === undefined) ? String(obj) : Object.prototype.toString.call(obj).match(/\[object (\w+)\]/)[1].toLowerCase()
  },
  isRegxString(str) {
    return str.charAt(0) === '/' && str.charAt(str.length - 1) === '/';
  },
  objToJsonStrShow(obj) {
    return JSON.stringify(obj, null, 4).replace(/\n|\r/g, "<br>").replace(/\s/g, "&nbsp;")
  },
  jsonStrFormat(str) {
    return str.replace(/\s/g, " ").replace(/\n/g, "").replace(/\r/g, "").replace(/\v/g, "");
  },
  constant: {
    objectType: {
      string: 'string',
      number: 'number',
      boolean: 'boolean',
      regexp: 'regexp'
    }
  }
}
